<?php 
session_start();
include 'conf/db-config.php';

if(strlen($_SESSION["u_name"])== 0)
{
 header("Location:index.php");
}
	$userID = $_SESSION['user_id'];
	$txtSchoolName = $_REQUEST["txtSchoolName"];
	$txtDocumentName = $_REQUEST["txtDocumentName"];
	$file = $_FILES["file"]["name"];
	$folder = "uploads/".$userID;
	mkdir($folder,0777);
	//$folder = $folder1."/".$txtDocumentName;	
    //mkdir($folder,0777); 
    $action = $_REQUEST['action'];
     
    if($action=="review" || $action=="review2")
    {
    	unlink(unlink($folder."/". $_FILES['file']['name']));  
    }
    move_uploaded_file($_FILES['file']['tmp_name'], $folder."/". $_FILES['file']['name']);
    $filepath = $folder."/". $_FILES['file']['name'];
    $package_no = $_REQUEST['package_no'];
    
  	if($action!="review" && $action!="review2")
    {
    	//move_uploaded_file($_FILES['file']['tmp_name'], $folder."/". $_FILES['file']['name']);
	   	$sql = "INSERT INTO tbl_admission_documents (user_id,school_name,document_name,document_path,is_review,package_no) VALUES ";
		$sql .="($userID,'$txtSchoolName','$txtDocumentName','$filepath',0,'$package_no')";
    }
    else
    {
    	//print "--->>".$action;
    	if($action=="review")
    	{
    		$isR =1;
    	}
    	else
    	{
    		$isR = 2;
    	}
    	//move_uploaded_file($_FILES['file']['tmp_name'], $folder."/". $_FILES['file']['name']);
    	$sql = "UPDATE tbl_admission_documents SET is_review='".$isR."', document_path='".$filepath."' WHERE package_no='".$package_no."'";
    	//print $sql;
    }
    //exit;
    mysql_query($sql);

?>
	<script>
	window.open('AdmissionConsulting.php','_self');
	</script>